<template>
	<div>
		<div id="slider" class="mui-slider">
			<div id="sliderSegmentedControl" class="mui-scroll-wrapper mui-slider-indicator mui-segmented-control mui-segmented-control-inverted">
				<div class="mui-scroll">
					<a :class="['mui-control-item', item.id == 0 ? 'mui-active' : '']" v-for="(item,index) in phototitles" :key='index'>
						{{ item.title }}
					</a>
				</div>
			</div>
		</div>
		<ul class="photo-list">
		  <router-link v-for="item in list" :key='item.id' :to="'/home/photoinfo/'+item.id" tag='li'>
		    <img v-lazy="item.img.img_url">
		    <p class="title">{{ item.title }}</p>
		    <p class="text" v-html="item.text"></p>
		  </router-link>
		</ul>
	</div>
</template>

<script>
	import mui from '../../lib/mui/js/mui.min.js'

	export default {
		data() {
			return {
				phototitles: [],
				list:[]
			}
		},
		mounted() {
			mui('.mui-scroll-wrapper').scroll({
				deceleration: 0.0005
			});
		},
		created() {
			this.getPhotoTitle();
		},
		methods: {
			getPhotoTitle() {
				this.$http.get('data.php').then(result => {
					if(result.body.status == true) {
//						result.body.photo_title.unshift({
//							title: '全部',
//							id: 0
//						});
						this.phototitles = result.body.photo_title;
						//						console.log(this.phototitles)
//						console.log(result.body.photo_img);
						this.list = result.body.photo_img;
						console.log(this.list.img)
					} else {
						Toast('获取图片列表头部信息失败...');
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	* {
		touch-action: pan-y;
	}
	.photo-list{
		li{
			width: 100%;
			list-style: none;
			/*background: #fff;*/
			img{
				width: 90%;
				display: block;
				margin: 8px 2px;
				border: 5px solid #fff;
				box-shadow: 0 0 5px dodgerblue;
			}
			img[lazy=loading] {
				width: 40px;
				height: 300px;
				margin: auto;
			}
			p{
				/*text-align: center;*/
			}
		}
	}
	
</style>